package com.education.teach.mvp.ui.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.education.teach.R;
import com.education.teach.mvp.model.bean.ExamBean;
import com.jess.arms.utils.ArmsUtils;

import java.util.List;

import dn.easy.common.commonutils.TimeUtil;

public class ExamAdapter extends BaseQuickAdapter<ExamBean.ResultBean.QueryListBean, BaseViewHolder> {

    public ExamAdapter(int layoutResId, @Nullable List<ExamBean.ResultBean.QueryListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ExamBean.ResultBean.QueryListBean item) {
        helper.setText(R.id.tv_new_title, item.getPaper().getTitle())
                .setText(R.id.tv_state, getState(item.getPaper().getAnswerState()))
                .addOnClickListener(R.id.btn_start)
                .setText(R.id.tv_new_date, TimeUtil.formatData(TimeUtil.dateFormatYMDHMofChinese, item.getPaper().getCTime()));
    }

    private String getState(int answerState) {
        String state = "";
        switch (answerState) {
            case -1:
                state = "未提交";
                break;
            case 0:
                state = "未提交";
                break;
            case 1:
                state = "已提交";
                break;
            case 2:
                state = "已批阅";
                break;
        }
        return state;
    }

}
